function add(a:number, b:number): number { 
  return a + b;
}

function sayHello1(name:string) {
  return "hello " + name;
}

const sayHello2 = function (name: string) { 
  return "hello " + name;
}

const sayHello3 = (name: string): string => { 
  return "hello " + name;
}

const sayHello4 = (name: string) => "hello " + name

const sayHello5 = (name: string) => {
  if (name === "admin") { 
    return "hello admin"
  }
  return;
}

const result = add(1, 2);

/* function sendMessage(userId: number, message?: string) {
  console.log(userId);
  console.log("message: ", message);
}

sendMessage(1) */

function sendMessage(userId: number, message="hello") {
  console.log(userId);
  console.log("message: ", message);
}

sendMessage(1, "hi")

/* function sum() { 
  return Array.from(arguments).reduce((result, item) => result + item, 0);
}

// @ts-ignore
const sumResult = sum(1, 2, 3, 4, 5);
console.log(sumResult); */

function sum(...numbers: number[]) { 
  return numbers.reduce((result, item) => result + item, 0);
}

const sumResult = sum(1, 2, 3, 4, 5);

function showDate(this: Date) { 
  return `${this.getFullYear()}-${this.getMonth() + 1}-${this.getDate()}`
};

const time = showDate.call(new Date());
// console.log(time);
// const time = showDate.call(null);

